package org.techmore.common.utils;

import android.os.HandlerThread;

public class HandlerThreadUtils {
	
	public static ThreadLocal<HandlerThread> handlerThread = new ThreadLocal<HandlerThread>();

	static HandlerThread myHandlerThread = new HandlerThread("thread-app");
	
	public static HandlerThread getHandlerThreadInstance(){
		if(null == handlerThread.get()){
			handlerThread.set(myHandlerThread);
			isStart();
			return myHandlerThread;
		}else{
			isStart();
			return handlerThread.get();
		}
	}
	
	private static void isStart(){
		if(!myHandlerThread.isAlive()){
			myHandlerThread.start();
		}
	}
	
}
